/**
 * 
 */
package com.omega.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.omega.dao.ItemDao;
import com.omega.entity.Item;
import com.omega.service.ItemService;

/**
 * @author vpan14
 *
 */
@Service
public class ItemServiceImpl implements ItemService {

	@Autowired
	ItemDao itemDao;
	
	@Override
	@Transactional(rollbackFor = Exception.class)
	public void addItem(Item portalItem) {
		itemDao.addItem(portalItem);
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public List<Item> loadAllItems() {
		return itemDao.loadAllItems();
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public Item loadById(Integer itemId) {
		return itemDao.loadById(itemId);
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public void updateItem(Item form) {
		Item itemEntity = itemDao.loadById(form.getitemId());
		itemEntity.setBrand(form.getBrand());
		itemEntity.setItemName(form.getItemName());
		itemDao.updateItem(itemEntity);
	}

}
